package pokerLogic2;

import neuroPoker.poker.Enums.GamePositions;

public class OpenRaiser {
	// wertet die SHC-Action ggf. nach dem ORC auf
	public Action getAction(PLKarte[] hand, Action action,
			GamePositions gamePosition) {
		if (gamePosition == GamePositions.UTG1)
			action = getUTGAction(action, hand);
		if (gamePosition == GamePositions.UTG2)
			action = getUTG1Action(action, hand);
		if (gamePosition == GamePositions.UTG3)
			action = getUTG2Action(action, hand);
		if (gamePosition == GamePositions.MP1)
			action = getMP1Action(action, hand);
		if (gamePosition == GamePositions.MP2)
			action = getMP2Action(action, hand);
		if (gamePosition == GamePositions.MP3)
			action = getMP3Action(action, hand);
		if (gamePosition == GamePositions.CO)
			action = getCOAction(action, hand);
		if (gamePosition == GamePositions.BU)
			action = getBUAction(action, hand);
		if (gamePosition == GamePositions.SB)
			action = getSBAction(action, hand);
		if (action.raise == 1)
			action.shcAction = "OpenRaise";
		return action;
	}

	public Action getUTGAction(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-99
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 9)
			openRaise = true;
		// AKo-AQo
		if (handStr.contains("A")
				&& (handStr.contains("K") || handStr.contains("Q")))
			openRaise = true;
		// AKs-ATs
		if (isSuited(hand) && handStr.contains("A")
				&& hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// KQs
		if (isSuited(hand) && handStr.contains("K") && handStr.contains("Q"))
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: UTG1 " + handStr);
		}
		return action;
	}

	public Action getUTG1Action(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-99
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 9)
			openRaise = true;
		// AKo-AQo
		if (handStr.contains("A")
				&& (handStr.contains("K") || handStr.contains("Q")))
			openRaise = true;
		// AKs-ATs
		if (isSuited(hand) && handStr.contains("A")
				&& hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// KQs
		if (isSuited(hand) && handStr.contains("K") && handStr.contains("Q"))
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: UTG2 " + handStr);
		}
		return action;
	}

	public Action getUTG2Action(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-88
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 8)
			openRaise = true;
		// AKo-AJo
		if (handStr.contains("A") && hand[0].wertInt + hand[1].wertInt >= 25)
			openRaise = true;
		// KQo
		if (handStr.contains("K") && handStr.contains("Q"))
			openRaise = true;
		// AKs-ATs
		if (handStr.contains("A") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// KQs-KJs
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: UTG3 " + handStr);
		}
		return action;
	}

	public Action getMP1Action(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-77
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 7)
			openRaise = true;
		// AKo-ATo
		if (handStr.contains("A") && hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// KQo
		if (handStr.contains("K") && handStr.contains("Q"))
			openRaise = true;
		// AKs-A9s
		if (handStr.contains("A") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// KQs-KJs
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// QJs
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 23)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: MP1 " + handStr);
		}
		return action;
	}

	public Action getMP2Action(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-66
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 6)
			openRaise = true;
		// AKo-ATo
		if (handStr.contains("A") && hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// KQo-KJo
		if (handStr.contains("Q") && hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// AKs-A9s
		if (handStr.contains("A") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// KQs-KTs
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// QJs-QTs
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 22)
			openRaise = true;
		// JTs
		if (handStr.contains("J") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 21)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: MP2 " + handStr);
		}
		return action;
	}

	public Action getMP3Action(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-55
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 5)
			openRaise = true;
		// AKo-A9o
		if (handStr.contains("A") && hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// KQo-KJo
		if (handStr.contains("K") && hand[0].wertInt + hand[1].wertInt >= 24)
			openRaise = true;
		// QJo
		if (handStr.contains("Q") && hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// AKs-A6s
		if (handStr.contains("A") && isSuited(hand) && handStr.contains("A")
				&& hand[0].wertInt + hand[1].wertInt >= 20)
			openRaise = true;
		// KQs-K9s
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 22)
			openRaise = true;
		// QJs-Q9s
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 21)
			openRaise = true;
		// JTs-J9s
		if (handStr.contains("J") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 20)
			openRaise = true;
		// T9s
		if (handStr.contains("T") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 19)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: MP3 " + handStr);
		}
		return action;
	}

	public Action getCOAction(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-44
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 4)
			openRaise = true;
		// AKo-A7o
		if (handStr.contains("A") && hand[0].wertInt + hand[1].wertInt >= 21)
			openRaise = true;
		// KQo-KTo
		if (handStr.contains("K") && hand[0].wertInt + hand[1].wertInt >= 23)
			openRaise = true;
		// QJo-QTo
		if (handStr.contains("Q") && hand[0].wertInt + hand[1].wertInt >= 22)
			openRaise = true;
		// JTo
		if (handStr.contains("J") && hand[0].wertInt + hand[1].wertInt >= 21)
			openRaise = true;
		// AKs-A2s
		if (handStr.contains("A") && isSuited(hand))
			openRaise = true;
		// KQs-K8s
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 21)
			openRaise = true;
		// QJs-Q8s
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 20)
			openRaise = true;
		// JTs-J8s
		if (handStr.contains("J") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 19)
			openRaise = true;
		// T9s
		if (handStr.contains("T") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 19)
			openRaise = true;
		// 98s
		if (handStr.contains("9") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 17)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: CO " + handStr);
		}
		return action;
	}

	public Action getBUAction(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-33
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 3)
			openRaise = true;
		// AKo-A2o
		if (handStr.contains("A"))
			openRaise = true;
		// KQo-K7o
		if (handStr.contains("K") && hand[0].wertInt + hand[1].wertInt >= 20)
			openRaise = true;
		// QJo-Q9o
		if (handStr.contains("Q") && hand[0].wertInt + hand[1].wertInt >= 21)
			openRaise = true;
		// JTo-J9o
		if (handStr.contains("J") && hand[0].wertInt + hand[1].wertInt >= 20)
			openRaise = true;
		// AKs-A2s
		if (handStr.contains("A") && isSuited(hand))
			openRaise = true;
		// KQs-K2s
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 15)
			openRaise = true;
		// QJs-Q6s
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 18)
			openRaise = true;
		// JTs-J7s
		if (handStr.contains("J") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 18)
			openRaise = true;
		// T9s-T8s
		if (handStr.contains("T") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 18)
			openRaise = true;
		// 98s
		if (handStr.contains("9") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 17)
			openRaise = true;
		// 87s
		if (handStr.contains("8") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 15)
			openRaise = true;
		// 76s
		if (handStr.contains("7") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 13)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: BU " + handStr);
		}
		return action;
	}

	public Action getSBAction(Action action, PLKarte[] hand) {
		boolean openRaise = false;
		String handStr = "" + hand[0] + hand[1];
		// AA-22
		if (hand[0].w == hand[1].w && hand[0].wertInt >= 2)
			openRaise = true;
		// AKo-A2o
		if (handStr.contains("A"))
			openRaise = true;
		// KQo-K3o
		if (handStr.contains("K") && hand[0].wertInt + hand[1].wertInt >= 16)
			openRaise = true;
		// QJo-Q4o
		if (handStr.contains("Q") && hand[0].wertInt + hand[1].wertInt >= 16)
			openRaise = true;
		// JTo-J5o
		if (handStr.contains("J") && hand[0].wertInt + hand[1].wertInt >= 16)
			openRaise = true;
		// T9o-T6o
		if (handStr.contains("T") && hand[0].wertInt + hand[1].wertInt >= 16)
			openRaise = true;
		// 98o-97o
		if (handStr.contains("9") && hand[0].wertInt + hand[1].wertInt >= 16)
			openRaise = true;
		// 87o
		if (handStr.contains("8") && hand[0].wertInt + hand[1].wertInt == 16)
			openRaise = true;
		// AKs-A2s
		if (handStr.contains("A") && isSuited(hand))
			openRaise = true;
		// KQs-K2s
		if (handStr.contains("K") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 15)
			openRaise = true;
		// QJs-Q2s
		if (handStr.contains("Q") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 14)
			openRaise = true;
		// JTs-J2s
		if (handStr.contains("J") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 13)
			openRaise = true;
		// T9s-T3s
		if (handStr.contains("T") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 13)
			openRaise = true;
		// 98s-94s
		if (handStr.contains("9") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 13)
			openRaise = true;
		// 87s-85s
		if (handStr.contains("8") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt >= 13)
			openRaise = true;
		// 76s
		if (handStr.contains("7") && isSuited(hand)
				&& hand[0].wertInt + hand[1].wertInt == 13)
			openRaise = true;
		if (openRaise) {
			action.raise = 1;
			Util.println("OpenRaise: SB " + handStr);
		}
		return action;
	}

	public boolean isSuited(PLKarte[] hand) {
		if (hand[0].f == hand[1].f)
			return true;
		return false;
	}
}
